<html>
<head><meta charset="utf-8"><title>visit `ForeignItem`s in `ItemLikeVisitor` · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html">visit `ForeignItem`s in `ItemLikeVisitor`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210605191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210605191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210605191">(Sep 19 2020 at 08:56)</a>:</h4>
<p>Are we intentionally not visiting <code>ForeignItem</code>s in <code>ItemLikeVisitor</code>?</p>
<p>If not, that's probably something we want to change <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="210607283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210607283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210607283">(Sep 19 2020 at 09:52)</a>:</h4>
<p>They aren't items, so we'd need a slew of new visitor functions to handle them</p>



<a name="210607541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210607541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210607541">(Sep 19 2020 at 10:00)</a>:</h4>
<p>they are pretty close to items, aren't they</p>



<a name="210607548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210607548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210607548">(Sep 19 2020 at 10:01)</a>:</h4>
<p><code>Visitor</code> already visits them</p>



<a name="210607551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210607551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210607551">(Sep 19 2020 at 10:01)</a>:</h4>
<p>afaik</p>



<a name="210607613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210607613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210607613">(Sep 19 2020 at 10:02)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/fn.walk_foreign_item.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/fn.walk_foreign_item.html</a></p>



<a name="210609371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210609371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210609371">(Sep 19 2020 at 10:54)</a>:</h4>
<p>oh huh... I guess then we should indeed do that</p>



<a name="210672927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210672927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210672927">(Sep 20 2020 at 16:07)</a>:</h4>
<p>If <code>ItemLikeVisitor</code> visits trait items without bodies, then it should probably visit foreign items as well, because these two are both item declarations without definitions (bodies), and are supposed to be treated equivalently by type checking and other similar passes implemented via  <code>ItemLikeVisitor</code>.</p>



<a name="210673531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210673531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210673531">(Sep 20 2020 at 16:21)</a>:</h4>
<p>See e.g. <a href="https://github.com/rust-lang/rust/pull/73323">https://github.com/rust-lang/rust/pull/73323</a> as an example of issues caused by foreign items not being visited.<br>
Perhaps other similar issues still exist.</p>



<a name="210673686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210673686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210673686">(Sep 20 2020 at 16:24)</a>:</h4>
<p>yeah, I think so too, will try and get a draft ready by next week here</p>



<a name="210702695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210702695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210702695">(Sep 21 2020 at 05:28)</a>:</h4>
<p>Found another bug here: <a href="https://github.com/rust-lang/rust/issues/76991">#76991</a></p>



<a name="210797366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210797366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210797366">(Sep 21 2020 at 20:44)</a>:</h4>
<p>hmm, so I am increasingly unsure on if adding <code>visit_foreign_item</code> is useful or if we "just" want to add a comment to <code>ItemLikeVisitor</code> recommending to look into <code>ForeignModule</code>s.</p>



<a name="210797460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/visit%20%60ForeignItem%60s%20in%20%60ItemLikeVisitor%60/near/210797460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/visit.20.60ForeignItem.60s.20in.20.60ItemLikeVisitor.60.html#210797460">(Sep 21 2020 at 20:45)</a>:</h4>
<p>trying to implement this, most <code>ItemLikeVisitors</code> don't care about foreign items and walking them probably has a small perf const</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>